package com.ln.第一遍1027.demo001;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/10/27 15:56
 */
public class Test001 {
    public static void main(String[] args) throws Exception{
        //1.通过类名直接获取
        Class pigClass = Pig.class;
        //2.通过对象直接获取
        Pig pig = new Pig();
        Class aClass = pig.getClass();
        //3.通过类名的全路径名获取
        Class aClass1 = Class.forName("com.ln.第一遍1027.demo001.Pig");

        System.out.println(pigClass==aClass);
        System.out.println(pigClass==aClass1);
        System.out.println(aClass==aClass1);

        Pig p1 = (Pig) pigClass.newInstance();
        Pig p2 =(Pig) aClass.newInstance();
        Pig p3 =(Pig) aClass1.newInstance();
        System.out.println(p1==p2);
        System.out.println(p1==p3);
        System.out.println(p3==p2);
    }
}
class Pig{

}
